
var Sequelize = require('sequelize')

var sequelize = new Sequelize('database', 'username', 'password', {
  host: 'localhost',
  dialect: 'sqlite',

  pool: {
    max: 5,
    min: 0,
    idle: 10000
  },

  // 仅 SQLite 适用
  storage: 'data.db'
});


// 创建一张表

var Question = sequelize.define('question',
  {
    id : {
      type : Sequelize.INTEGER,
      field: 'id',
      primaryKey: true
    },
    explain :{
      type : Sequelize.TEXT
    },
    label :{
      type :Sequelize.STRING
    },
    mediaHeight : {
      type : Sequelize.FLOAT
    },
    mediaWidth : {
      type : Sequelize.FLOAT
    },
    mediaType : {
      type : Sequelize.INTEGER
    },
    optionA : {
      type : Sequelize.STRING(1024)
    },
    optionB : {
      type : Sequelize.STRING(1024)
    },
    optionC : {
      type : Sequelize.STRING(1024)
    },
    optionD : {
      type : Sequelize.STRING(1024)
    },
    optionE : {
      type : Sequelize.STRING(1024)
    },
    optionF : {
      type : Sequelize.STRING(1024)
    },
    optionG : {
      type : Sequelize.STRING(1024)
    },
    optionH : {
      type : Sequelize.STRING(1024)
    },
    optionType :{
      type : Sequelize.INTEGER
    },
    question :{
      type : Sequelize.TEXT
    },
    mediaContent : {
      type : Sequelize.TEXT(528)
    },
    falseCount : {
      type : Sequelize.INTEGER
    },
    trueCount : {
      type : Sequelize.INTEGER
    },
    wrongRate : {
      type : Sequelize.FLOAT
    }
  },
  {
    freezeTableName: true
  });


Question.sync({force: true}).then(()=>{
  console.log('Create Table [Question] success')
});



module.exports.Question = Question;
